function requestSync(urls, options = {}, limits = 3) {
  let num = Math.ceil(urls.length / limits);
  let func = async (arr) => {
    let [urls, options, result] = arr;
    let group = urls.splice(0, limits);
    let res = await Promise.all(group.map((url) => request(url, options)));
    console.log(`${limits} 个已完成` + new Date().getTime());
    result.push(res);
    return [urls, options, result];
  };
  return Array(num)
    .fill(func)
    .reduce((next, current) => {
      return next.then(current);
    }, Promise.resolve([urls, options, []]))
    .then((res) => res.pop());
}

/**
 * 请求封装
 * @date 2020-08-18
 * @param {String} url
 * @param {Object} options
 * @returns {Promise}
 */
function request(url, options) {
  if (typeof url === "object") {
    options = url.options(options);
    url = url.url;
  }
  return new Promise((resolve, reject) => {
    fetch(url, options)
      .then((res) => res.text())
      .then((res) => resolve(res))
      .catch((err) => reject(err));
  });
}
